Skip to content

fix(state): converge render-phase updates (v3.5.3)#49

Merged
monstercameron merged 1 commit into
masterfrom
react-parity/fix-render-phase-update
Jun 25, 2026
Merged

fix(state): converge render-phase updates (v3.5.3)#49
monstercameron merged 1 commit into
masterfrom
react-parity/fix-render-phase-update

Conversation

@monstercameron

Copy link
Copy Markdown
Owner

A component updating its own state during render committed a value it never rendered and never converged. renderFunctionComponent now re-runs to convergence (bounded 25, via a precise activeRenderFiber flag), matching React. Found bug-hunting state management. Full suite + native/wasm pass, no regression. Ships as v3.5.3.

🤖 Generated with Claude Code

… output (v3.5.3)

A component that updated its own state during render (the derived-state pattern,
if x { setState(...) }) stored the new value and scheduled a commit, but the
component was never re-run — so the committed DOM showed a value the component had
not actually rendered (rendered 0, DOM showed 1) and never converged.

renderFunctionComponent now detects a render-phase update via a new
Runtime.activeRenderFiber flag (set only around the actual render call, distinct
from the ambient currentFiber so the SSR path and hook unit tests that set
currentFiber manually are unaffected) and re-runs the component to convergence,
bounded at 25 iterations with a diagnostic to guard an unconditional-setState
infinite loop. Matches React's "keeps restarting until there are no more new
updates."

The hook setter, when its owner == activeRenderFiber, marks the fiber
renderPhaseUpdate and returns without scheduling (the convergence loop handles
re-render). Found bug-hunting GWC's state management against React. Covered by
TestRenderPhaseUpdateConverges / DerivedStateOneStep / UnconditionalDoesNotHang;
full suite + native/wasm pass, no regression.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@monstercameron monstercameron merged commit f2566e3 into master Jun 25, 2026
3 checks passed
@monstercameron monstercameron deleted the react-parity/fix-render-phase-update branch June 25, 2026 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants